package com.baturu.vin.byd.dal.dao;

import com.baturu.vin.byd.dto.BydVinInfoDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 比亚迪获取在线vin车型信息
 * @author jiangxinlei
 * @Time 2017/8/25.
 */
public interface BydQueryResultDAO {

    @Insert({"INSERT INTO byd_vin",
            "(vinCode, carSystem, year, carType, engine, colorName, gearBox, brandName, btrId, unKnownId, versionId,carSystemId,carTypeId,mjId) VALUES",
            "(#{dto.vinCode},#{dto.carSystem},#{dto.year},#{dto.carType},#{dto.engine},#{dto.colorName},#{dto.gearBox},#{dto.brandName}, #{dto.btrId},",
            "#{dto.unKnownId}, #{dto.versionId}, #{dto.carSystemId}, #{dto.carTypeId},#{dto.mjId})",
            "ON DUPLICATE KEY UPDATE",
            "carSystem = #{dto.carSystem},",
            "year = #{dto.year},",
            "carType = #{dto.carType},",
            "engine = #{dto.engine},",
            "colorName = #{dto.colorName},",
            "gearBox = #{dto.gearBox},",
            "brandName = #{dto.brandName},",
            "btrId = #{dto.btrId},",
            "unKnownId = #{dto.unKnownId},",
            "versionId = #{dto.versionId},",
            "carSystemId = #{dto.carSystemId},",
            "carTypeId = #{dto.carTypeId},",
            "mjId = #{dto.mjId}"})
    int createOrUpdateCarInfo(@Param("dto") BydVinInfoDTO vinInfoDTO);

    @Select({"select distinct carSystemId from byd_qp_carsystem where carSystem = #{carSystem} and brandName = #{brandName} limit 1"})
    Integer findCarSystemId(@Param("carSystem") String carSystem, @Param("brandName") String brandName);

}
